

#include "stdafx.h"
#include "CombatState_Standby.h"
#include "Combat/EvtCombat.h"
#include "Event/EvtImp.h"
#include "Combat/CombatSysImp.h"
#include "Entity/EntityIf.h"
#include "Combat/CombatDefinition.h"



CombatState_Standby::CombatState_Standby(void)
{
}

CombatState_Standby::~CombatState_Standby()
{
}

void
CombatState_Standby::enter()
{
	//
	//	I am losing my target when standby
	m_wpCombat->setTargetCE(0);
}

void
CombatState_Standby::leave()
{
}

bool 
CombatState_Standby::update(int nElapse)
{
	return true;
}

void 
CombatState_Standby::onEvent(IEvt& evt)
{
	if (evt.getID()==EVT_CastStart)
	{
		if (m_wpCombat->isCalculator())
		{
			m_wpCombat->onEvent_Cast(evt);
			m_wpCombat->setState(Combat::CBS_Ready);
		}
		else
		{
			LOG_ERROR_V("Failed to cast start in : %d !\n", m_wpCombat->getStateName());
		}
	}
	else if (evt.getID()==EVT_CastEnd)
	{
		LOG_ERROR_V("Failed to cast end in : %d !\n", m_wpCombat->getStateName());
	}
	else if (evt.getID()==EVT_CastResult)
	{
		m_wpCombat->onEvent_CastResult(evt);
	}
	else if (evt.getID()==EVT_CastPrep)
	{
		m_wpCombat->onEvent_CastPrep(evt);
		m_wpCombat->setState(Combat::CBS_Ready);
	}
	else if (evt.getID()==EVT_TargetSelected)
	{
		m_wpCombat->onEvent_Target(evt);
		m_wpCombat->setState(Combat::CBS_Ready);
	}
}

